package org.tarena.dang.action.main;



import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.tarena.dang.action.BaseAction;
import org.tarena.dang.entity.Book;
import org.tarena.dang.service.BookService;
import org.tarena.dang.service.BookServiceImp;



public class BookAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	private Book book;
	private int id;
	

	public String execute() throws Exception {
		BookService bookService = new BookServiceImp();
		System.out.println("显示详情ID"+id);
		book = bookService.findByProId(id);
		Cookie cookie1 = new Cookie("h", id+"");
		cookie1.setMaxAge(30000);
		//cookie.put(Constant.HISTORY, id+"");
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		response.addCookie(cookie1);
		System.out.println("cookie ok");
		System.out.println(cookie1.getValue());
		System.out.println("***"+cookie.size());
		//response.addCookie(c2);
		return "success";
	}
	public Book getBook() {
		return book;
	}
	public void setBook(Book book) {
		this.book = book;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
}
